<template>
  <div >
    <div>
      <div class="font15 mt10 pl10">
      <span class="titletext ">{{titledata.title}}</span>
      <div class="graytext  mt10 font13">
        <span >工单编号：</span>
        <span class="titletext">{{titledata.pmInsId}}</span>
      </div>
    </div>
    <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
      <div class="blue_item" />
      <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">项目-商机信息</span>
    </div>
    <!-- 基本信息 -->
      <van-field readonly required name="provinceCode" :value="provinceCode" label="归属省：" label-width="4em" />
      <van-field readonly required name="cityCode" :value="cityCode" label="归属地市：" label-width="5em" />
      <van-field readonly required name="publicCountyCode" :value="publicCountyCode" label="区县公司：" label-width="5em" />
      <van-field readonly required name="busiOpportunityName" :value="fromdata.busiOpportunityName" label="商机名称：" label-width="5em" />
      <van-field readonly required name="busiOpportunityNumber" :value="fromdata.busiOpportunityNumber" label="商机编码：" label-width="5em" />
      <van-field readonly required name="createDate" :value="fromdata.bigBillFillApply.createDate" label="商机创建时间：" label-width="7em" />
      <van-field readonly required name="ictFlag" :value="fromdata.ictFlag=='Y'?'是':'否'" label="是否ICT项目：" label-width="7.25em" />
      <van-field readonly name="projectName" :value="fromdata.projectName" label="全网项目名称：" label-width="7em" />
      <van-field readonly required name="groupProjectCode" :value="fromdata.groupProjectCode" label="ICT项目编码/标品订单编码：" label-width="13em" />
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">合同信息</span>
      </div>
      <van-field readonly required name="dictIncomeAmount" :value="fromdata.bigBillFillApply.dictIncomeAmount" label="DICT合同收入(含税,元)：" label-width="12em" />
      <van-field readonly required name="dictContractIncomeRatio" :value="fromdata.bigBillFillApply.dictContractIncomeRatio" label="DICT合同收入占比(%)：" label-width="12em" />
      <van-field readonly required name="contractAmount" :value="fromdata.bigBillFillApply.contractAmount" label="合同总金额(含税,元)：" label-width="11.25em" />
      <van-field readonly required name="budgetTfSigenAmount" :value="fromdata.bigBillFillApply.budgetTfSigenAmount" label="项目通服签约金额(含税,元)：" label-width="14em" />
      <van-field readonly required name="budgetItTfSigenAmount" :value="fromdata.bigBillFillApply.budgetItTfSigenAmount" label="项目IT通服签约总金额(含税,元)：" label-width="15em" />
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item" />
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">前向合同</span>
      </div>
      <el-table :data="bigBillFillApplyList" border style="width: 100%">
        <el-table-column prop="contractCode" label="合同编码" width="120"/>
        <el-table-column prop="signingTime" label="签约时间" width="120"/>
        <el-table-column prop="contractTerm" label="合同年限(年)" width="120"/>
        <el-table-column prop="createCompanyCode" label="承办单位编码" width="120"/>
        <el-table-column prop="createCompanyName" label="	承办单位名称" width="120"/>
      </el-table>
      <van-field readonly name="mainIncomeRatio" :value="fromdata.bigBillFillApply.mainIncomeRatio" label="主营收入占比(%)：" label-width="9.25em" />
      <van-field readonly name="profitMargin" :value="fromdata.bigBillFillApply.profitMargin" label="利润率(%)：" label-width="6.25em" />
      <van-field readonly required name="industryCategoryValue" :value="industryCategoryValue" label="行业类别：" label-width="5em" />
      <van-field readonly required name="groupCustomerName" :value="fromdata.bigBillFillApply.groupCustomerName" label="客户名称：" label-width="5em" />
      <van-field readonly required name="groupCustomerCode" :value="fromdata.bigBillFillApply.groupCustomerCode" label="全网客户编码：" label-width="7em" />
      <van-field readonly required name="doubleCountProjectFlag" :value="fromdata.bigBillFillApply.doubleCountProjectFlag=='Y'?'是':'否'" label="是否双计双考项目：" label-width="9em" />
      <van-field readonly required name="projectManagerName" :value="fromdata.bigBillFillApply.projectManagerName" label="项目经理姓名：" label-width="7em" />
      <van-field readonly required name="itServiceRevenueAmount" :value="fromdata.bigBillFillApply.itServiceRevenueAmount" label="IT通服收入金额(含税,元)：" label-width="12em" />
      <van-field readonly name="projectAmountCollected" :value="fromdata.bigBillFillApply.projectAmountCollected" label="项目已计收金额(元)：" label-width="10.5em" />
      <van-field readonly required name="projectManagerPhone" :value="fromdata.bigBillFillApply.projectManagerPhone" label="项目经理电话：" label-width="7em" />
      <van-field readonly required name="recordUpdateTime" :value="fromdata.bigBillFillApply.recordUpdateTime" label="最近更新时间：" label-width="7em" />
      <van-field readonly name="isUpload" :value="fromdata.bigBillFillApply.isUpload" label="大单填报状态：" label-width="7em" />
      <van-field readonly required autosize type="textarea" rows="1" name="brief" :value="fromdata.bigBillFillApply.brief" label="项目简介：" label-width="5em" />
      <historyAndSuggs id='target' :showHistory='showHistory' :historydata='historydata' :approveList='approveList' />
    </div>
  </div>
</template>
 
<script>
import historyAndSuggs from "@/views/srqr/historyAndSuggs.vue";
import {getCountyCode,queryOneDictIndustry} from "@/api/dictapi";
import {Notify} from "vant";
import {mapGetters} from "vuex";
export default {
  data() {
    return {
      provinceCode:'',
      cityCode:'',
      publicCountyCode:'',
      industryCategoryValue:'',
      bigBillFillApplyList:[],
      firstCheck:true
    }
  },
  props: ['titledata','businessdata','fromdata','showHistory','historydata','approveList','todotype','showcChengbanView'],
  computed: {
    ...mapGetters(['user']),
  },
  watch: {
    fromdata: {
      handler () { //这是vue的规定写法，当你watch的值发生变化的时候，就会触发这个handler，这是vue内部帮你做的事情
          this.setdata();
      },
      deep: true,  // 可以深度检测到 obj 对象的属性值的变化
      immediate: true //刷新加载  立马触发一次handler
    }
  },
  methods: {
     tomsg () {
      document.getElementById('target').scrollIntoView({ behavior: 'smooth' })
    },
    setdata(){
      getCountyCode(Object.assign({ userName: this.user.userName }))
          .then((result) => {
            if (!result.data) {
              Notify(result.message);
              return;
            }
            for(var i=0;i<result.data.data.length;i++){
              if(result.data.data[i].cityCode==this.fromdata.cityCode){
                this.cityCode = result.data.data[i].cityName;
                this.provinceCode = result.data.data[i].provinceName;
              }
            }
          })
      getCountyCode(Object.assign({ cityName: this.fromdata.cityCode,userName: this.user.userName }))
          .then((result) => {
            if (!result.data) {
              Notify(result.message);
              return;
            }
            for(var i=0;i<result.data.data.length;i++){
              if(result.data.data[i].value==this.fromdata.publicCountyCode){
                this.publicCountyCode = result.data.data[i].name;
              }
            }
          })
      queryOneDictIndustry(Object.assign({ userName: this.user.userName }))
          .then((result) => {
            if (!result.data) {
              Notify(result.message);
              return;
            }
            for(var i=0;i<result.data.data.length;i++){
              if(result.data.data[i].nineMajorindustriesCode==this.fromdata.bigBillFillApply?.industryCategory){
                this.industryCategoryValue = result.data.data[i].nineMajorindustriesName;
              }
            }
          })
      this.bigBillFillApplyList= [this.fromdata.bigBillFillApply]
      console.log('转换后的数据是',this.bigBillFillApplyList)
    }
  },
  components: {
    historyAndSuggs
  },
}
</script>
 
<style>
.tables.el-table .cell {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    line-height: 15px;
    padding-left: 5px;
    padding-right: 5px;
}
</style>